﻿using System.ComponentModel;
using CardPlay.Model.CardModel;

namespace CardPlay.Model.GameModel.Presentation
{
    public class BaseCues : INotifyPropertyChanged
    {
        private SiteType _site = SiteType.None;
        private Suit[] _suits;
        private Rank? _rank;

        public readonly Suit[] NoSuits = new Suit[] {};

        public event PropertyChangedEventHandler PropertyChanged;

        public bool IsDealSource
        {
            get;
            set;
        }

        public bool AllowsRedeal
        {
            get;
            set;
        }

        public SiteType Site
        {
            get { return _site; }
            set
            {
                if (value == Site) return;
                _site = value;
                NotifyOfPropertyChanged("Site");
            }
        }

        public Rank? Rank
        {
            get { return _rank; }
            set
            {
                if (value == Rank) return;
                _rank = value;
                NotifyOfPropertyChanged("Rank");
            }
        }

        public Suit[] Suits
        {
            get { return _suits; }
            set
            {
                _suits = value ?? NoSuits;
                NotifyOfPropertyChanged("Suits");
            }
        }

        private void NotifyOfPropertyChanged(string propertyName)
        {
            var callback = PropertyChanged;
            if (callback != null) callback(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}